
package com.insigma.business.qrcode.common.converter;

import com.insigma.business.qrcode.soldier.dto.SoldierPetitionInfoDTO;
import com.insigma.business.qrcode.soldier.entity.SoldierPetitionInfoDO;
import com.insigma.business.qrcode.soldier.request.SoldierPetitionInfoBSearcher;
import com.insigma.business.qrcode.soldier.request.SoldierPetitionInfoInsertRequest;
import com.insigma.business.qrcode.soldier.request.SoldierPetitionInfoSearchRequest;
import com.insigma.business.qrcode.soldier.request.SoldierPetitionInfoUpdateRequest;
import org.springframework.beans.BeanUtils;

import java.util.List;


public class SoldierPetitionInfoProviderConverter extends AbstractConverter<SoldierPetitionInfoDTO, SoldierPetitionInfoDO> {

    private final static SoldierPetitionInfoProviderConverter soldierPetitionInfoConverter = new SoldierPetitionInfoProviderConverter();

    private SoldierPetitionInfoProviderConverter(){}

    
    public static SoldierPetitionInfoBSearcher convertRequestSO2Searcher(final SoldierPetitionInfoSearchRequest request){
        final SoldierPetitionInfoBSearcher soldierPetitionInfoBSearcher = new SoldierPetitionInfoBSearcher(request.getPageNo(),
        request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,soldierPetitionInfoBSearcher);
        return soldierPetitionInfoBSearcher;
    }

    
    public static SoldierPetitionInfoDO convertRequestUO2DO(final SoldierPetitionInfoUpdateRequest soldierPetitionInfoUpdateRequest) {
        final SoldierPetitionInfoDO soldierPetitionInfoDO = new SoldierPetitionInfoDO();
        BeanUtils.copyProperties(soldierPetitionInfoUpdateRequest,soldierPetitionInfoDO);
        
        return soldierPetitionInfoDO;
    }

    
    public static SoldierPetitionInfoDO convertRequestIO2DO(final SoldierPetitionInfoInsertRequest soldierPetitionInfoInsertRequest) {
        final SoldierPetitionInfoDO soldierPetitionInfoDO = new SoldierPetitionInfoDO();
        BeanUtils.copyProperties(soldierPetitionInfoInsertRequest,soldierPetitionInfoDO);
        return soldierPetitionInfoDO;
    }

    
    public static List<SoldierPetitionInfoDTO> convertResponseDOList2DTOList(final List<SoldierPetitionInfoDO> soldierPetitionInfoDOList){
        return soldierPetitionInfoConverter.convertGenericResponseDOList2DTOList(soldierPetitionInfoDOList);
    }

    
    public static SoldierPetitionInfoDTO convertResponseDO2DTO(final SoldierPetitionInfoDO soldierPetitionInfoDO){
        return soldierPetitionInfoConverter.convertGenericResponseDO2DTO(soldierPetitionInfoDO);
    }

    
    @Override
    protected SoldierPetitionInfoDTO doConvertResponseDO2DTO(SoldierPetitionInfoDO soldierPetitionInfoDO) {
        final SoldierPetitionInfoDTO soldierPetitionInfoDTO = new SoldierPetitionInfoDTO();
        try {
            BeanUtils.copyProperties(soldierPetitionInfoDO, soldierPetitionInfoDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return soldierPetitionInfoDTO;
    }

}
